//! Copyright 2012 NTH Technology, Inc.
//! All rights reserved
//!
#include "stm32f10x.h"
#include "BoardHardware.h"
#include "Config.h"
#include "LedDriver.h"

cSysTick cLedDriver::s_LedTick;

void cLedDriver::InitReset()
{
    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_APB2PeriphClockCmd(LED_PERIPH, ENABLE);
    GPIO_InitStructure.GPIO_Pin = LED_PIN;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(LED_PORT, &GPIO_InitStructure);
    DEBUG_LED_OFF;
    s_LedTick.SetTimeout(cConfig::LED_REV_TIME);
    s_LedTick.ResetTimeBase();
}

void cLedDriver::SetLed(bool on)
{
    if (true == on) DEBUG_LED_ON;
    else DEBUG_LED_OFF;
}

void cLedDriver::RunOne()
{
    if (true == s_LedTick.CheckTimeOut())
    {
        s_LedTick.ResetTimeBase();
        DEBUG_LED_INV;
    }
}

